package com.hlx.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatHistoryMapper {

	/**
	 * 根据chatId查询会话
	 * @param chatId
	 * @return
	 */
	@Select("select count(*) from chat_history_ids where chat_id = #{chatId}")
	int selectByChatId(String chatId);

	/**
	 * 保存会话id
	 * @param type
	 * @param chatId
	 */
	@Insert("insert into chat_history_ids (type, chat_id) values (#{type}, #{chatId})")
	void save(String type, String chatId);

	/**
	 * 根据type查询会话id
	 * @param type
	 * @return
	 */
	@Select("select chat_id from chat_history_ids where type = #{type}")
	List<String> selectByType(String type);
}
